<template>
  <div class="container">
    <Loader v-if="isLoading" text="加载中。。。" background="rgba(0,0,0,0.7)" />
    <!-- <Message type="error" :message="errorMsg.message" v-if="errorMsg.status" /> -->
    <GlobalHeader :user="currentUser">
    </GlobalHeader>
    <router-view />
    <GlobalFooterVue />
  </div>
</template>
<script lang="ts" setup>
import "bootstrap/dist/css/bootstrap.min.css";
import { computed, onMounted, watch } from "vue";
import { useStore } from "vuex";
// import Message from "@/components/Message.vue";
import createMessage from "@/components/createMessage";
import Loader from "@/components/Loader.vue";
import GlobalHeader from "@/components/GlobalHeader.vue";
import GlobalFooterVue from "@/components/GlobalFooter.vue";
const store = useStore();
//用户数据
const currentUser = computed(() => store.state.user);
// loading
const isLoading = computed(() => {
  return store.state.loading
})
const errorMsg = computed(() => store.state.error)
// const token = computed(() => store.state.token)
// onMounted(() => {
//   if (!currentUser.value.isLogin && token.value) {
//     store.dispatch('fetchCurrentUser')
//   }
// })

watch(() => errorMsg.value.status, () => {
  const { status, message } = errorMsg.value
  if (status && message) {
    createMessage(message, 'error')
  }
})
</script>
<style lang="scss">
</style>
